package codeforces;

import java.util.Scanner;

public class TooLongWords {

	private static final int n = 10;
	
	private static String modify(String s) {
		StringBuilder res = new StringBuilder(s);
		int length = s.length();
		if(length > n) {
			res.replace(1, length - 1, String.valueOf(length - 2));
			return res.toString();
		}
		return s;
	}
	
	public static void main(String[] args) {
		
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		String[] output = new String[n];
		
		int i = 0;
		while(i < n) {
			output[i] = modify(s.next());
			i++;
		}
		for (int j = 0; j < output.length; j++) {
			System.out.println(output[j]);
		}
	}

}
